package System_code;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-08-09
 * Time: 15:58
 */
public class Demo26 {
    public static void main(String[] args) throws InterruptedException {
        ReentrantLock locker = new ReentrantLock();
        Thread t1 = new Thread(() -> {
            locker.tryLock();
            try {
                while (true) {

                    System.out.println("卢世杰");

                    Thread.sleep(1000);
                }
                } catch(InterruptedException e){
                    e.printStackTrace();
                }

        });
        t1.start();
        locker.tryLock();
        while (true) {
            System.out.println("main");
            Thread.sleep(1000);
        }
    }
}
